<?php

/**
 * BeatUpload actions.
 *
 * @package    sf_sandbox
 * @subpackage BeatUpload
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 2288 2006-10-02 15:22:13Z fabien $
 */
class BeatUploadActions extends autoBeatUploadActions
{
  public function executeList()
  {
    $this->processSort();

    $this->processFilters();


    // pager
    $this->pager = new sfPropelPager('BeatUpload', 20);
    $c = new Criteria();
    $c->addAscendingOrderByColumn(BeatUploadPeer::STATUS);
    $c->addDescendingOrderByColumn(BeatUploadPeer::CREATED);
    $this->addSortCriteria($c);
    $this->addFiltersCriteria($c);
    $this->pager->setCriteria($c);
    $this->pager->setPage($this->getRequestParameter('page', $this->getUser()->getAttribute('page', 1, 'sf_admin/beat_upload')));
    $this->pager->init();
    // save page
    if ($this->getRequestParameter('page')) {
        $this->getUser()->setAttribute('page', $this->getRequestParameter('page'), 'sf_admin/beat_upload');
    }
  }
  
 public function executeDelete()
  {
    $this->beat_upload = BeatUploadPeer::retrieveByPk($this->getRequestParameter('id'));
    $this->forward404Unless($this->beat_upload);

    try
    {
      #$path = '/home/thangtv2/work/sources/iring/iringstorage'.$this->beat_upload->getLinkfile();// local
      $path = '/data/ringtone/beat_upload';// Sever
      unlink($path);
      $this->deleteBeatUpload($this->beat_upload);
    }
    catch (PropelException $e)
    {
      $this->getRequest()->setError('delete', 'Could not delete the selected Beat upload. Make sure it does not have any associated items.');
      return $this->forward('BeatUpload', 'list');
    }

    return $this->redirect('BeatUpload/list');
  }
}
